package work.comeback.omo.service.imp;


import org.jsoup.nodes.Document;
import work.comeback.omo.dao.crawler.ICrawler;
import work.comeback.omo.dao.crawler.imp.CrawlerImpl;
import work.comeback.omo.model.movie.MovieTask;
import work.comeback.omo.service.CrawlerService;

public class CrawlerServiceImpl implements CrawlerService {

    ICrawler crawlerImpl = new CrawlerImpl();

    public static void main(String[] args) {
        CrawlerServiceImpl crawlerService = new CrawlerServiceImpl();

        for (int i = 1; i < 10; i++) {
            crawlerService.add(new MovieTask("https://subocaiji.com/api.php/provide/vod", "/?ac=list&pg=%d".formatted(i), "?ac=detail&ids="));
        }

        crawlerService.executeAllTasks();
    }

    @Override
    public void add(MovieTask... mvs) {
        crawlerImpl.add(mvs);
    }

    @Override
    public <T> T parse(Document document, Class<T> classOfT) {
        return crawlerImpl.parse(document, classOfT);
    }

    @Override
    public void executeTask(String taskId) {
        crawlerImpl.executeTask(taskId);
    }

    @Override
    public void executeAllTasks() {
        crawlerImpl.executeAllTasks();
    }
}
